<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,viewport-fit=cover,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
    <title>尤迈桃李会</title>
    <script src="js/rem.js"></script>
    <link rel="stylesheet" href="css/weui.min.css">
    <link rel="stylesheet" href="css/jquery-weui.min.css">
    <link rel="stylesheet" href="css/public.css">
    <link rel="stylesheet" href="css/index.css">
    <script>(function() {var _53code = document.createElement("script");_53code.src = "https://tb.53kf.com/code/code/96d8f960b261e49515450f8953b044bc5/1";var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(_53code, s);})();</script>
</head>
<body>
    <div class="login-wrapper plr15">
        <div class="tit">修改密码</div>
        <form action="#" autocomplete="off" method="post" onsubmit="passSubmit(); return false;" id="setPassWord">
            <ul class="list">
                <li><input class="input" name="password" type="password" placeholder="设置密码"></li>
                <li><input class="input" name="confirmPassword" type="password" placeholder="再次输入密码"></li>
            </ul>
            <input class="pub-submit-btn pass-conf-btn" type="submit" value="确定">
        </form>
    </div>
    <script src="js/jquery-3.6.0.min.js"></script>
    <script src="js/jquery-weui.min.js"></script>
    <script src="js/md5.js"></script>
    <script src="js/public.js"></script>
    <script>
        var state = false;
        function passSubmit(){
            if(state) return false;
            var options = $('#setPassWord').serializeObject()
            ,password = options.password
            ,confirmPassword = options.confirmPassword;

            if(validEmpty(password, '请输入密码')) return false;
            if(validEmpty(confirmPassword, '请再次输入密码')) return false;
            if(password !== confirmPassword){
                toast('两次密码输入不一致');
                return false;
            } 
            if(!validPass(password)) return false;
            state = true;
            http('/user/updatePassword', {
                loading: true,
                hasToken: false,
                data: {
                    loginMobile: localStorage.getItem('mobile'),
                    password: md5(password)
                },
                success: function(res){
                    if(res.code === '01'){
                        toast('密码设置成功');
                        setTimeout(function(){
                            window.location.href = 'user-setting.html'
                        }, 1000)
                    }
                },
                complete: function(){
                    state = false;
                }
            })
            return false;
        }
    </script>
</body>
</html>